<template>
    <view>
        <status-bar title='运营公告' :goHome='fromShare'></status-bar>
        <view v-if="list.length">
            <view class="item padding30" v-for="(item,index) in list" :key="index" @click="toUrl('/joinPage/noticeDetail?log_id=' + item.log_id)">
                <view class="d-flex j-sb a-center m-bot20">
                    <view class="size34 color_22 bold">{{ item.title }}</view>
                    <!-- 未读1、已读0 -->
                    <view class="dot" v-if="item.unread == 1"></view>
                </view>
                <view class="h6 color_66">{{ item.addDate }}</view>
            </view>
        </view>

        <empty v-if="noData" cat='3' msg='您还没有相关的公告'></empty>
    </view>
</template>

<script>
export default {
    data(){
        return {
            fromShare: 0,
            store_id: '',
            list: [],
            noData: false
        }
    },
    onLoad(e){
        if(e.fromShare) this.fromShare = e.fromShare
        if(e.store_id) this.store_id = e.store_id
    },
    onShow(){
        this.getList()
    },
    methods: {
        getList(){
            this.$http.post({
                url: '/osmxcxApi/getStoreTradeLog',
                data: {
                    store_id: this.store_id,
                    page: 1,
                    pageNum: 999
                }
            }).then(res=>{
                if(res.errcode != 100) return this.$Toast(res.msg)
                this.list = res.data || []
                if(this.list.length){
                    this.noData = false
                }else{
                    this.noData = true
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.item {
    border-bottom: 1rpx solid #D9D9D9;
    .dot {
        width: 20rpx;
        height: 20rpx;
        background: #FF5C5C;
        border-radius: 50%;
    }
}
</style>